import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//导入进度条nprogress的js和css
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

//导入axios
import axios from 'axios'
//设置根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//在发送请求头添加token验证,拦截器
axios.interceptors.request.use(config => {
  // 显示进度条
  Nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
//在response拦截器中，隐藏进度条 nprogress.done()
axios.interceptors.response.use(config => {
  Nprogress.done()
  return config
})

Vue.prototype.$http = axios

//导入全局样式表
import './assets/css/index.css'
//导入外部图标样式
import './assets/fonts/iconfont.css'
import './plugins/element.js'
import  'element-ui/lib/theme-chalk/index.css'

//导入富文本样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'


//导入富文本编辑器
import vueQuillEditor from 'vue-quill-editor'

Vue.use(vueQuillEditor)

Vue.config.productionTip = false

//导入三方插件
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)

Vue.filter('dateFormat',function(originVal){
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2,'0')
  const hh = (dt.getHours() + '').padStart(2,'0')
  const mm = (dt.getMinutes() + '').padStart(2,'0')
  const ss = (dt.getSeconds() + '').padStart(2,'0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})



new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
